package com.zuihai.app.mvp.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.zuihai.app.R;
import com.zuihai.app.mvp.model.entity.FindItem;
import com.zuihai.app.mvp.ui.holder.BaseViewHolderWraper;
import com.zuihai.app.mvp.ui.utils.GildeUtils;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Administrator on 2017/5/4 0004.
 */

public class FindRecyclerAdapter extends BaseQuickAdapter<FindItem, BaseViewHolderWraper> {

    private Context context;
    private int width;
    public FindRecyclerAdapter(List<FindItem> infos) {

        super(R.layout.layout_item_find, infos);
    }
    public FindRecyclerAdapter(List<FindItem> infos,int width,Context context) {

        super(R.layout.layout_item_find, infos);
        this.width=width;
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolderWraper helper, FindItem item) {
        ImageView imageView=helper.getView(R.id.iv_cover);
        ViewGroup.LayoutParams lp = imageView.getLayoutParams();
        lp.height = (int) (width* 0.5625);
        imageView.setLayoutParams(lp);
        if (item.picture != null && !item.picture.isEmpty()) {
            helper.loadImage(R.id.iv_cover, item.picture.get(0).pictureUrl);
        }
        CircleImageView headimage=helper.getView(R.id.civ_find_headimage);
        GildeUtils.headImageGlide(context,item.releaser_touxiang,headimage);
        helper.setText(R.id.tv_title, item.title);
        helper.setText(R.id.tv_auther, item.auther);
        helper.setText(R.id.tv_comment, String.format("%s", item.commentCount));
        helper.setText(R.id.tv_favour, String.format("%s", item.favourCount));
    }
}
